// Copyright DustedPixels.com 2008. All rights reserved.

package units;

import java.io.FileInputStream;
import java.io.InputStream;
import java.io.PrintWriter;

import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.util.TraceClassVisitor;

/**
 * @author micapolos@gmail.com (Michal Pociecha-Los)
 */
public final class UnitsTest {
  public static void main(String[] args) throws Exception {
    Nand.Context nandContext = new Nand.Context() {
      public int getInput1() {return 0x0F;}
      public int getInput2() {return 0x33;}
      public void setOutput(int value) {System.out.println(Integer.toString(value & 0xFF, 16));}
    };
    Nand nand = new Nand(nandContext);
    nand.update();
    
    asmify("bin/units/Nand.class");
  }
  
  static void asmify(String filename) throws Exception {
    InputStream input = new FileInputStream(filename);
    try {
      ClassReader reader = new ClassReader(input);
      ClassVisitor asmifier = new TraceClassVisitor(new PrintWriter(System.out));
      reader.accept(asmifier, 0);
    } finally {
      input.close();
    }
  }
}
